import java.util.Scanner;

public class Day_19_1_汽水瓶 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            int count = 0;
            int n = sc.nextInt();
            if(n == 0) {
                break;
            }
            if(n > 0) {
                while(n > 1) {
                    count += n / 3;
                    n = n % 3 + n / 3;
                    if(n == 2) {
                        count ++;
                        n = 0;
                    }
                }
            }
            System.out.println(count);
        }
    }
}
